package com.hjm.project.terminal.posCount.service.impl;

import com.hjm.project.agentInfo.agentInfo.domain.AgentInfo;
import com.hjm.project.agentInfo.agentInfo.mapper.AgentInfoMapper;
import com.hjm.project.terminal.posCount.domain.PosCount;
import com.hjm.project.terminal.posCount.mapper.PosCountMapper;
import com.hjm.project.terminal.posCount.service.PosCountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 展业端管理激活量
 * 
 */
@Service
public class PosCountServiceImpl implements PosCountService {
    @Resource
    private PosCountMapper posCountMapper;

    @Resource
    private AgentInfoMapper agentInfoMapper;

    /**
     * 查询展业端管理激活量
     *
     * @param  posCount 终端信息
     * @return 终端型号
     */
    @Override
    public List<PosCount> selectPosCountList(PosCount posCount)
    {
        return posCountMapper.selectPosCountList(posCount);
    }
    @Override
    public PosCount selectPosCountSum(PosCount posCount)
    {
        return posCountMapper.selectPosCountSum(posCount);
    }

    /**
     * 查询展业端管理激活量
     *
     * @param  posCount 终端信息(非一段达标)
     * @return 终端型号
     */
    @Override
    public List<PosCount> selectPosTwoCountList(PosCount posCount)
    {
        return posCountMapper.selectPosTwoCountList(posCount);
    }

    @Override
    public List<PosCount> selectAgentPosCountOne(PosCount posCount) {
        AgentInfo agentInfo = agentInfoMapper.selectAgentInfoById(posCount.getAgentNum());
        PosCount pos = new PosCount();
        pos.setAgentNum(agentInfo == null ? "" : agentInfo.getAgentNum());
        pos.setPosType(posCount.getPosType());
        List<PosCount> posCounts = posCountMapper.selectAgentPosCountOne(pos);
        for (PosCount count : posCounts) {
            if(count != null){
                count.setAgentNum(agentInfo == null ? "" : agentInfo.getAgentNum());
                count.setAgentName(agentInfo == null ? "" : agentInfo.getAgentName());
            }
        }
        return posCounts;
    }

}
